@@ -30,6 +30,7 @@ |
||
| 30 | 30 |
<script src="scripts/controllers/sidebar-ctrl.js"></script> |
| 31 | 31 |
<script src="scripts/controllers/note-view-ctrl.js"></script> |
| 32 | 32 |
<script src="scripts/controllers/note-edit-ctrl.js"></script> |
| 33 |
+ <script src="scripts/controllers/image-view-ctrl.js"></script> |
|
| 33 | 34 |
<script src="scripts/services/file-service.js"></script> |
| 34 | 35 |
<script src="scripts/services/search-service.js"></script> |
| 35 | 36 |
<script src="scripts/services/thumbnail-service.js"></script> |
@@ -18,6 +18,7 @@ angular |
||
| 18 | 18 |
'codexApp.sidebar', |
| 19 | 19 |
'codexApp.noteView', |
| 20 | 20 |
'codexApp.noteEdit', |
| 21 |
+ 'codexApp.imageView', |
|
| 21 | 22 |
'hljs' |
| 22 | 23 |
]) |
| 23 | 24 |
|
@@ -54,6 +55,11 @@ angular |
||
| 54 | 55 |
templateUrl: "views/note-edit.html", |
| 55 | 56 |
controller: 'NoteEditCtrl' |
| 56 | 57 |
}) |
| 58 |
+ .state('image-view', {
|
|
| 59 |
+ url: "/image-view", |
|
| 60 |
+ templateUrl: "views/image-view.html", |
|
| 61 |
+ controller: 'ImageViewCtrl' |
|
| 62 |
+ }) |
|
| 57 | 63 |
$urlRouterProvider.otherwise("/");
|
| 58 | 64 |
|
| 59 | 65 |
|
@@ -16,15 +16,15 @@ angular.module('codexApp.index', [])
|
||
| 16 | 16 |
$timeout(function() {
|
| 17 | 17 |
switch ($scope.view) {
|
| 18 | 18 |
case "All Notes": |
| 19 |
- var note = {
|
|
| 20 |
- type : "All Notes" |
|
| 21 |
- } |
|
| 19 |
+ var note = { type : "All Notes" }
|
|
| 22 | 20 |
FileService.setCurrentNote(note); |
| 23 | 21 |
$scope.files = FileService.getAllNotes(); |
| 24 | 22 |
var info = $scope.files.length + " Notes" |
| 25 | 23 |
$rootScope.$broadcast('footer:info', info);
|
| 26 | 24 |
break; |
| 27 | 25 |
case "All Files": |
| 26 |
+ var note = { type : "All Files" }
|
|
| 27 |
+ FileService.setCurrentNote(note); |
|
| 28 | 28 |
$scope.files = FileService.getAllFiles(); |
| 29 | 29 |
var info = $scope.files.length + " Files" |
| 30 | 30 |
$rootScope.$broadcast('footer:info', info);
|
@@ -71,6 +71,11 @@ angular.module('codexApp.index', [])
|
||
| 71 | 71 |
PrefsService.setCurrentView("Notebook");
|
| 72 | 72 |
$scope.setView(); |
| 73 | 73 |
break; |
| 74 |
+ case "Image": |
|
| 75 |
+ FileService.setCurrentNote(file) |
|
| 76 |
+ $rootScope.$broadcast('main-window:note-view');
|
|
| 77 |
+ $state.go("image-view");
|
|
| 78 |
+ break; |
|
| 74 | 79 |
} |
| 75 | 80 |
} |
| 76 | 81 |
|
@@ -0,0 +1,115 @@ |
||
| 1 |
+ |
|
| 2 |
+ |
|
| 3 |
+/** |
|
| 4 |
+ * @ngdoc function |
|
| 5 |
+ * @name domainManagerApp.controller:AboutCtrl |
|
| 6 |
+ * @description |
|
| 7 |
+ * # AboutCtrl |
|
| 8 |
+ * Controller of the domainManagerApp |
|
| 9 |
+ */ |
|
| 10 |
+angular.module('codexApp.imageView', [])
|
|
| 11 |
+ .controller('ImageViewCtrl',['$scope', '$rootScope', '$state', 'FileService', function ($scope, $rootScope, $state, FileService) {
|
|
| 12 |
+ |
|
| 13 |
+ var filesystem = require("fs");
|
|
| 14 |
+ |
|
| 15 |
+ console.log('-> Image View opened!')
|
|
| 16 |
+ |
|
| 17 |
+ $scope.note = FileService.getCurrentNote(); |
|
| 18 |
+ $scope.container = "note-container"; |
|
| 19 |
+ $scope.image_path = $scope.note.path; |
|
| 20 |
+ |
|
| 21 |
+ |
|
| 22 |
+ |
|
| 23 |
+ |
|
| 24 |
+ |
|
| 25 |
+ $scope.fixRelativeURL = function(current_url, relative_url) {
|
|
| 26 |
+ console.log("-> Fixing URL")
|
|
| 27 |
+ console.log(" * Relative URL: " + relative_url)
|
|
| 28 |
+ console.log(" * Note URL: " + current_url)
|
|
| 29 |
+ // split urls and create arrays |
|
| 30 |
+ var current_path = current_url.split('/');
|
|
| 31 |
+ var relative_path = relative_url.split('/');
|
|
| 32 |
+ // remove the current note's filename from the url |
|
| 33 |
+ current_path.pop(); |
|
| 34 |
+ // count how many folders the relative path goes back and erase '..' |
|
| 35 |
+ var count = 0; |
|
| 36 |
+ for (var i = 0; i < relative_path.length; i++) {
|
|
| 37 |
+ if(relative_path[i] == ".."){
|
|
| 38 |
+ count = count + 1; |
|
| 39 |
+ relative_path[i] = ""; |
|
| 40 |
+ } |
|
| 41 |
+ } |
|
| 42 |
+ // make the relative path a string again |
|
| 43 |
+ relative_path = relative_path.join('/');
|
|
| 44 |
+ // remove the same count of folders from the end of the current notes url |
|
| 45 |
+ for (var i = 0; i < count; i++) {
|
|
| 46 |
+ current_path.pop(); |
|
| 47 |
+ } |
|
| 48 |
+ // make the current note's url a string again |
|
| 49 |
+ current_path = current_path.join('/');
|
|
| 50 |
+ // add a '/' if the relative url pointed to a file or folder above the current notes root |
|
| 51 |
+ if(count == 0){
|
|
| 52 |
+ var fixed_url = current_path + "/" + relative_path; |
|
| 53 |
+ } else {
|
|
| 54 |
+ var fixed_url = current_path + relative_path; |
|
| 55 |
+ } |
|
| 56 |
+ // return the fixed relative url |
|
| 57 |
+ console.log(" * Fixed URL: " + fixed_url)
|
|
| 58 |
+ return fixed_url; |
|
| 59 |
+ } |
|
| 60 |
+ |
|
| 61 |
+ |
|
| 62 |
+ |
|
| 63 |
+ $scope.absoluteToRelativeURL = function(current_url, absolute_url) {
|
|
| 64 |
+ console.log("-> Converting absolute URL to relative")
|
|
| 65 |
+ console.log(" * Absolute URL: " + absolute_url)
|
|
| 66 |
+ console.log(" * Note URL: " + current_url)
|
|
| 67 |
+ // split urls and create arrays |
|
| 68 |
+ var current_path = current_url.split('/');
|
|
| 69 |
+ var absolute_path = $scope.getUrlParts(absolute_url).pathname.split('/');
|
|
| 70 |
+ // remove the current note's filename from the url and the image filename from the url |
|
| 71 |
+ current_path.pop(); |
|
| 72 |
+ current_path.shift(); |
|
| 73 |
+ absolute_path.shift(); |
|
| 74 |
+ // count how many folders the current path has |
|
| 75 |
+ var current_path_count = 0; |
|
| 76 |
+ for (var i = 0; i < current_path.length; i++) {
|
|
| 77 |
+ current_path_count = current_path_count + 1; |
|
| 78 |
+ } |
|
| 79 |
+ // count how many folders the absolute path has |
|
| 80 |
+ var absolute_path_count = 0; |
|
| 81 |
+ for (var i = 0; i < absolute_path.length; i++) {
|
|
| 82 |
+ absolute_path_count = absolute_path_count + 1; |
|
| 83 |
+ } |
|
| 84 |
+ absolute_path_count = absolute_path_count - 1; |
|
| 85 |
+ console.log(" * Cleaned current URL (" + current_path_count + " parts): " + current_path.join('/'))
|
|
| 86 |
+ console.log(" * Cleaned absolute URL (" + absolute_path_count + " parts): " + absolute_path.join('/'))
|
|
| 87 |
+ dif = current_path_count - (absolute_path_count -1); |
|
| 88 |
+ for (var i = 0; i < absolute_path_count; i++) {
|
|
| 89 |
+ absolute_path.shift(); |
|
| 90 |
+ } |
|
| 91 |
+ console.log(" * Modified current URL (" + current_path_count + " parts): " + current_path.join('/'))
|
|
| 92 |
+ console.log(" * Modified absolute URL (" + absolute_path_count + " parts): " + absolute_path.join('/'))
|
|
| 93 |
+ // make the relative path a string again |
|
| 94 |
+ var relative_path = absolute_path.join('/');
|
|
| 95 |
+ console.log(" * Converted relative URL: " + relative_path)
|
|
| 96 |
+ return relative_path; |
|
| 97 |
+ } |
|
| 98 |
+ |
|
| 99 |
+ $scope.getUrlParts = function(url) {
|
|
| 100 |
+ var a = document.createElement('a');
|
|
| 101 |
+ a.href = url; |
|
| 102 |
+ |
|
| 103 |
+ return {
|
|
| 104 |
+ href: a.href, |
|
| 105 |
+ host: a.host, |
|
| 106 |
+ hostname: a.hostname, |
|
| 107 |
+ port: a.port, |
|
| 108 |
+ pathname: a.pathname, |
|
| 109 |
+ protocol: a.protocol, |
|
| 110 |
+ hash: a.hash, |
|
| 111 |
+ search: a.search |
|
| 112 |
+ }; |
|
| 113 |
+ } |
|
| 114 |
+ |
|
| 115 |
+ }]); |
@@ -534,7 +534,7 @@ angular.module('codexApp')
|
||
| 534 | 534 |
note_history.push(current_note); |
| 535 | 535 |
note_history_index = note_history.length -1; |
| 536 | 536 |
|
| 537 |
- //console.log(current_note); |
|
| 537 |
+ console.log(current_note); |
|
| 538 | 538 |
//console.log("Current_note: " + current_note.title)
|
| 539 | 539 |
} |
| 540 | 540 |
|
@@ -542,9 +542,7 @@ angular.module('codexApp')
|
||
| 542 | 542 |
if(note_history_index > 0) {
|
| 543 | 543 |
note_history_index = note_history_index - 1; |
| 544 | 544 |
current_note = note_history[note_history_index]; |
| 545 |
- if(current_note.path == "search" || current_note.path == undefined){
|
|
| 546 |
- changeController(); |
|
| 547 |
- } |
|
| 545 |
+ changeController(); |
|
| 548 | 546 |
$rootScope.$broadcast('window-view:change');
|
| 549 | 547 |
$rootScope.$broadcast('note-view:reload');
|
| 550 | 548 |
} |
@@ -555,9 +553,7 @@ angular.module('codexApp')
|
||
| 555 | 553 |
if(note_history_index < (note_history.length - 1)){
|
| 556 | 554 |
note_history_index = note_history_index + 1; |
| 557 | 555 |
current_note = note_history[note_history_index]; |
| 558 |
- if(current_note.path == "search" || current_note.path == undefined){
|
|
| 559 |
- changeController(); |
|
| 560 |
- } |
|
| 556 |
+ changeController(); |
|
| 561 | 557 |
$rootScope.$broadcast('window-view:change');
|
| 562 | 558 |
$rootScope.$broadcast('note-view:reload');
|
| 563 | 559 |
} |
@@ -593,10 +589,17 @@ angular.module('codexApp')
|
||
| 593 | 589 |
case "Folder": |
| 594 | 590 |
$state.go("index");
|
| 595 | 591 |
break; |
| 592 |
+ case "Image": |
|
| 593 |
+ $state.go("image-view");
|
|
| 594 |
+ break; |
|
| 596 | 595 |
case "All Notes": |
| 597 | 596 |
PrefsService.setCurrentView("All Notes");
|
| 598 | 597 |
$state.go("index");
|
| 599 | 598 |
break; |
| 599 |
+ case "All Files": |
|
| 600 |
+ PrefsService.setCurrentView("All Files");
|
|
| 601 |
+ $state.go("index");
|
|
| 602 |
+ break; |
|
| 600 | 603 |
} |
| 601 | 604 |
} |
| 602 | 605 |
|
@@ -0,0 +1,3 @@ |
||
| 1 |
+<div style="width: 100%; height: 100%; overflow: hidden;"> |
|
| 2 |
+ <img src="{{image_path}}" class="centered" style="max-width: 100%; max-height: 100%">
|
|
| 3 |
+</div> |
@@ -233,3 +233,11 @@ code.hljs .hljs-title {
|
||
| 233 | 233 |
animation-fill-mode:forwards; |
| 234 | 234 |
animation-duration:0.2s; |
| 235 | 235 |
} |
| 236 |
+ |
|
| 237 |
+.centered {
|
|
| 238 |
+ position: relative;; |
|
| 239 |
+ top: 50%; |
|
| 240 |
+ left: 50%; |
|
| 241 |
+ /* bring your own prefixes */ |
|
| 242 |
+ transform: translate(-50%, -50%); |
|
| 243 |
+} |